﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Auto.Data.Common;
using Auto.Web.Common;

namespace Auto.BusMan.UserControl
{
    public partial class ucKeepSubDivLabel : System.Web.UI.UserControl
    {
        #region --Property--


        /// <summary>
        /// Label
        /// </summary>
        public Label Label
        {
            get { return lblDiv; }
        }

        /// <summary>
        /// Width of Label
        /// </summary>
        public Unit Width
        {
            set { lblDiv.Width = value; }
        }

        /// <summary>
        /// DivID of SubDiv
        /// </summary>
        public string DivID
        {
            get { return (ViewState["DivID"] == null) ? "" : (string)ViewState["DivID"]; }
            set { ViewState["DivID"] = value; }
        }
        /// <summary>
        /// Text
        /// </summary>
        public string Text
        {
            get { return lblDiv.Text; }
            set
            {
                InitControl(value);
            }
        }
        #endregion --Property--

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// Fill the Data to the Control
        /// </summary>
        private void InitControl(string subDivID)
        {
            Auto.Data.Systems.Model.SubDivision subDiv = new Auto.Data.Systems.BLL.SubDivision().GetModel(DivID, subDivID);
            string divName = string.Empty;
            if (subDiv != null)
            {
                divName = subDiv.ShortDivName;
            }
            lblDiv.Text = divName;
        }

        /// <summary>
        /// Set Value by DivID And SubDivID
        /// </summary>
        /// <param name="divID"></param>
        /// <param name="subDivID"></param>
        public void InitControl(string divID, string subDivID)
        {
            Auto.Data.Systems.Model.SubDivision subDiv = new Auto.Data.Systems.BLL.SubDivision().GetModel(divID, subDivID);
            string divName = string.Empty;
            if (subDiv != null)
            {
                divName = subDiv.ShortDivName;
            }
            lblDiv.Text = divName;
        }

    }
}